package com.xinyue.sparkle.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.xinyue.sparkle.bean.User;
import com.xinyue.sparkle.dao.UserDao;
import com.xinyue.sparkle.service.UserService;


@Controller
public class _RootController {
	
	@Autowired
	private UserService service;

	@RequestMapping(method=RequestMethod.GET, value="/user/userManager")
	public ModelAndView userManagerPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mv = new ModelAndView("/one");
		
		User user = new User();
		user.setAddress("西安");
		user.setUserName("王夜");
		user.setPassword("111111");

		service.save(user);
		
		List<User> users = service.queryUser();
		for (User u: users) {
			System.out.println(u.getUserId());
		}
		
		return mv;
	}
}
